package cn.tedu.oa_system.controller;

import cn.tedu.oa_system.base.json_result.ResultDataDto;
import cn.tedu.oa_system.base.json_result.ResultDto;
import cn.tedu.oa_system.pojo.User;
import cn.tedu.oa_system.pojo.in.*;
import cn.tedu.oa_system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author MW
 * @Description 用户管理控制层
 * @CreateDate 2023/1/6
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    @PostMapping("/list")
    private ResultDataDto<User> list(@RequestBody PageIn pageIn){
        return userService.list(pageIn);
    };

    @PostMapping("/findbasekey")
    private ResultDataDto<User> findBaseKey(@RequestBody FindLikeKeyIn likeKeyIn){
        return userService.findLikeKey(likeKeyIn);
    }

    @PostMapping("/addnewuser")
    private ResultDto<Void> addNewUser(@RequestBody AddNewUserIn addNewUserIn){
        return userService.addNewUser(addNewUserIn);
    }

    @PostMapping("/updateuser")
    private ResultDto<Void> updateUser(@RequestBody UpdateUserIn updateUserIn){
        return userService.updateUser(updateUserIn);
    }

    @PostMapping("/deleteuser")
    private ResultDto<Void> deleteUser(@RequestBody UserIn userIn){
        return userService.deleteUser(userIn);
    };
}
